$(function() {
  $('.btn-visual-list li a').click(function() {
    if ($(this).parent().attr('id') == 'btn-visual') {
      $('#sakura-layer-1, #sakura-layer-2').snowfall('clear');   
      sakura();
    } else {
      $('#sakura-layer-1, #sakura-layer-2').snowfall('clear');
      var target = $(this).attr('href').substr(1);
    return false;
  });
    if ($('.news-txt img', this)[0]) {
      var imgPath = '/' + $('.news-txt img', this).attr('src').substr(0, 36) + 'w230';
      $('.topics-thumb', this).css('background-image', 'url(' + imgPath + ')');
    }
    var textTrim = $('.news-txt', this).text().substr(0, 60);
    $('.topics-txt', this).html(textTrim + '&nbsp;...');
    var target = $(this);
    setTimeout(function() {
      $(target).fadeIn(300);
    }, 200 * i);
  });
    items:{
      visible: 1,
      width: 195,
      height: 210
    },
    scroll:{
      items: 1,
      fx: 'scroll',
      duration: 300,
      pauseOnHover: true
    },
    auto:{
      play: true,
      timeoutDuration: 8000
    },
    prev: '.prev',
    next: '.next'
  }, {
    wrapper:{
      classname: 'twitter_update_list_wrap'
    }
  });
});
$(window).load(function() {
  $('#loading').fadeOut(500, function() {
    $('#top-header').animate({'left': 0}, 500);
    $('#right-box').animate({'right': 0}, 500);
    $('#chara-layer-1, #chara-layer-2').fadeIn(500);
  });
  setTimeout(function() {
    sakura();
  }, 1000);
});
function sakura() {
  $('#sakura-layer-1').snowfall({flakeCount: 3, flakeIndex: -1, image: 'https://sakura-flakes.googlecode.com/svn/trunk/sakura-', minSize: 24, maxSize: 64, minSpeed: 4, maxSpeed: 7});
  $('#sakura-layer-2').snowfall({flakeCount: 7, flakeIndex: -3, image: 'https://sakura-flakes.googlecode.com/svn/trunk/sakura-', minSize: 4, maxSize: 12, minSpeed: 1, maxSpeed: 4});
}